<template>
    <div>
      <h1>测试页</h1>
      <!-- 使用params传递参数 -->
      <p v-if="idFromParams">Received ID (Params): {{ idFromParams }}</p>
      <!-- 使用query传递参数 -->
      <p v-if="idFromQuery">Received ID (Query): {{ idFromQuery }}</p>
    </div>
  </template>
  
  <script>
  export default {
    computed: {
      idFromParams() {
        return this.$route.params.id;
      },
      idFromQuery() {
        return this.$route.query.id;
      }
    }
  }
  </script>